#include <bits/stdc++.h>
/*LUOGU 月赛重题了*/
using namespace std;
char	s1[10], s2[10], ss1[3][3], ss2[3][3], c;
int	top1, top2;
bool	flag1, flag2 = false;
inline int read(){
    int x=0;
    char ch;
    while((ch=getchar())!=' '&&ch!='\n'){
        x=x*10+ch-'0';
    }
    return x;
}
char a(int bbll){
    if(bbll==0) return 'X';
    else if(bbll==1) return 'A';
    else if(bbll==2) return 'B';
    else if(bbll==3) return 'C';
    else if(bbll==4) return 'X';
    else return 'F'/*UCK YOU*/;
}
int main()
{

    // for (int i=1;i<=2;++i)
    //     for (int j=1;j<=2;++j)
    //             cin >> ss1[i][j];
    // for(int i=1;i<=2;++i)
    //     for(int j=1;j<=2;++j)
    //         cout<<ss1[i][j];
    int a1=read(),a2=read(),a3=read(),a4=read(),b1=read(),b2=read(),b3=read(),b4=read();
	ss1[1][1]=a(a1);
    ss1[1][2]=a(a2);
    ss1[2][1]=a(a3);
    ss1[2][2]=a(a4);
    if(a1==4||a2==4||a3==4||a4==4||b1==4||b2==4||b3==4||b4==4){
        if(a1+1!=a2||a1-1!=a2||a1-1!=a3||a1+1!=a3) {
            puts("No");
        }
        else puts("Yes");
        return 0;
    }
    if ( ss1[1][1] != 'X' )
		s1[++top1] = ss1[1][1];
	if ( ss1[1][2] != 'X' )
		s1[++top1] = ss1[1][2];
	if ( ss1[2][2] != 'X' )
		s1[++top1] = ss1[2][2];
	if ( ss1[2][1] != 'X' )
		s1[++top1] = ss1[2][1];
	// for ( int i = 1; i <= 2; ++i )
	// 	for ( int j = 1; j <= 2; ++j )
	// 		cin >> ss2[i][j];
    ss2[1][1]=a(b1);
    ss2[1][2]=a(b2);
    ss2[2][1]=a(b3);
    ss2[2][2]=a(b4);
	if ( ss2[1][1] != 'X' )
		s2[++top2] = ss2[1][1];
	if ( ss2[1][2] != 'X' )
		s2[++top2] = ss2[1][2];
	if ( ss2[2][2] != 'X' )
		s2[++top2] = ss2[2][2];
	if ( ss2[2][1] != 'X' )
		s2[++top2] = ss2[2][1];
	for ( int k = 1; k <= 3; ++k )
	{
		flag1 = true;
		for ( int i = 1, j = top1 - 2; i <= 3; ++i, ++j )
			if ( s1[j] != s2[i] )
			{
				flag1 = false;
				break;
			}
		if ( flag1 == true )
		{
			flag2 = true;
			break;
		}
		int p = top1 + 1;
		s1[p] = s1[top1 - 2];
		++top1;
	}
	if ( flag2 )
		printf( "Yes" );
	else printf( "No" );
	return(0);
}